package com.hzsai.utils;

import java.io.Serializable;

public class ResponseMsg implements Serializable{

    private int code;
    private String msg;
    private Object data;

    public ResponseMsg() {
    }

    public ResponseMsg(int code, String msg, Object obj) {
        this.code = code;
        this.msg = msg;
        this.data = obj;
    }

    public static ResponseMsg success() {
        return new ResponseMsg(200, "成功了", null);
    }

    public static ResponseMsg success(Object obj) {
        return new ResponseMsg(200, "成功", obj);
    }

    public static ResponseMsg success(int code, String msg, Object obj) {
        return new ResponseMsg(code, msg, obj);
    }

    public static ResponseMsg fail() {
        return new ResponseMsg(200, "失败了", null);
    }

    public static ResponseMsg fail(int code, String msg, Object obj) {
        return new ResponseMsg(code, msg, obj);
    }

    public void setMsg(int code, String msg, Object obj) {
        this.code = code;
        this.msg = msg;
        this.data = obj;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getObj() {
        return data;
    }

    public void setObj(Object obj) {
        this.data = obj;
    }

    @Override
    public String toString() {
        return "code: " + this.code + "msg: " + this.msg + "data: " + this.data.toString();
    }
}
